import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import svgLoader from 'vite-svg-loader'
import { mockPlugin } from './mock'
import { componentsAutoImport } from './components.auto.import'

export function vitePlugin(configEnv, resolve) {
	const plugins = [
		vue(),
		vueJsx(),
		svgLoader(),
		...componentsAutoImport(),
	]
	// 本地开发
    if (configEnv.command === 'serve') {
        plugins.push(mockPlugin(configEnv, resolve))
    }
	return plugins
}